<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>Liste des Cliniques</title>
		<style type="text/css" title="currentStyle">
			@import "<?php echo base_url();?>css/demo_page.css";
			@import "<?php echo base_url();?>css/demo_table.css";
		</style>
		<script type="text/javascript" language="javascript" src="<?php echo base_url();?>js/jquery-1.9.1.min.js"></script>
		<script type="text/javascript" language="javascript" src="<?php echo base_url();?>js/jquery.dataTables.js"></script>
		 <link rel="stylesheet" href="<?php echo base_url();?>css/jquery-ui.css" />
		<script type="text/javascript" src="<?php echo base_url();?>js/jquery-ui.js"></script>
		<script>
			function infoclinique(identification){
				var url = "<?php echo base_url();?>index.php/admin/infoclinique?id="+identification;
				window.open(url,'recupcanet','menubar=no, scrollbars=yes, top=100, left=100, width=700, height=500, target=_blank');
			}
			function infoEquipe(identification){
				var url = "<?php echo base_url();?>index.php/admin/infoEquipe?id="+identification;
				window.open(url,'recupcanet','menubar=no, scrollbars=yes, top=100, left=100, width=700, height=500, target=_blank');
			}
			function infoTarif(identification){
				var url = "<?php echo base_url();?>index.php/admin/infoTarif?id="+identification;
				window.open(url,'recupcanet','menubar=no, scrollbars=yes, top=100, left=100, width=700, height=500, target=_blank');
			}
			function infoGalImage(identification){
				var url = "<?php echo base_url();?>index.php/admin/infoGalImage?id="+identification;
				window.open(url,'recupcanet','menubar=no, scrollbars=yes, top=100, left=100, width=700, height=500, target=_blank');
			}
			function validClinique(identification){
				var url = "<?php echo base_url();?>index.php/admin/validClinique?identification="+identification;
				$.post(url, {identification : identification},				
					function(data){
						var urlredirect = "<?php echo base_url(); ?>index.php/admin/listclinic";
						document.location = urlredirect;
					}
				);
			}
			function supprimer(identification){
				var url = "<?php echo base_url();?>index.php/admin/supprimerClinic?identification="+identification;
				if(window.confirm("Voulez-vous vraiment supprimer cette clinique??")){	
					$.post(url, {identification : identification},				
						function(data){
							var urlredirect = "<?php echo base_url(); ?>index.php/admin/listclinic";
							document.location = urlredirect;
						}
					);
				}	
			}
			function envoiemail(identification){
				var url = "<?php echo base_url();?>index.php/newsletter/newsletterClinic?id="+identification;
				window.open(url,'recupcanet','menubar=no, scrollbars=yes, top=100, left=100, width=700, height=500, target=_blank');
			}
				
		</script>
		<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#tableresult').dataTable({
				    "bProcessing": true,
				    "bDestroy": true,
				    "iDisplayLength": 50,
				    "aLengthMenu": [[50, 100, 200, -1], [50, 100, 200, "All"]],
				    "sServerMethod": "POST",
				    "sAjaxSource": "<?php echo base_url();?>index.php/admin/listClinicJson",
				    "sAjaxDataProp": "aaData",
					"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
						var imgLink = aData['logo'];
						var imgTag = '<img width="100" src="<?php echo base_url();?>upload/' + imgLink + '"/>';
						$('td:eq(1)', nRow).html(imgTag);
						var identification = $('td:eq(0)', nRow).text();
						var buttonTag1 = '<input type="button" value="Aper&ccedil;u" onclick="infoclinique('+identification+')" /> ';
						$('td:eq(3)', nRow).html(buttonTag1);
						var buttonTag2 = '<input type="button" value="Aper&ccedil;u" onclick="infoEquipe('+identification+')" />';
						$('td:eq(4)', nRow).html(buttonTag2);
						var buttonTag3 = '<input type="button" value="Aper&ccedil;u" onclick="infoTarif('+identification+')" />';
						$('td:eq(5)', nRow).html(buttonTag3);
						var buttonTag4 = '<input type="button" value="Aper&ccedil;u" onclick="infoGalImage('+identification+')" />';
						$('td:eq(6)', nRow).html(buttonTag4);
						var buttonTag5 = '<input type="button" value="Valider" onclick="validClinique('+identification+')" />';				
						var isOK = aData['isOK'];
						if(isOK == 1){
							$('td:eq(7)', nRow).html("Validé");
						}else{
							$('td:eq(7)', nRow).html(buttonTag5);
						}
						var buttonTag6 = '<input type="button" value="Supprimer" onclick="supprimer('+identification+')" />';
						$('td:eq(8)', nRow).html(buttonTag6);
						var buttonTag7 = '<input type="button" value="Envoyer un email" onclick="envoiemail('+identification+')" />';
						$('td:eq(9)', nRow).html(buttonTag7);
						return nRow;
					},		
				    "aoColumns": [
						{ "mData": "id_clinique" },
						{ "mData": "logo" },
						{ "mData": "nom_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" }
			        ]
				});
				
				$("#Voir").on('click', function() {
					var filtre = $("#filtre").val();
				 	$('#tableresult').dataTable({
					    "bProcessing": true,
					    "bDestroy": true,
					    "iDisplayLength": 50,
					    "aLengthMenu": [[50, 100, 200, -1], [50, 100, 200, "All"]],
					    "sServerMethod": "POST",
					    "sAjaxSource": "<?php echo base_url();?>index.php/admin/listClinicTriJson?id="+filtre,
					    "sAjaxDataProp": "aaData",	
						"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
						var imgLink = aData['logo']; 
						var imgTag = '<img width="100" src="<?php echo base_url();?>upload/' + imgLink + '"/>';
						$('td:eq(1)', nRow).html(imgTag);
						var identification = $('td:eq(0)', nRow).text();
						var buttonTag1 = '<input type="button" value="Aper&ccedil;u" onclick="infoclinique('+identification+')" /> ';
						$('td:eq(3)', nRow).html(buttonTag1);
						var buttonTag2 = '<input type="button" value="Aper&ccedil;u" onclick="infoEquipe('+identification+')" />';
						$('td:eq(4)', nRow).html(buttonTag2);
						var buttonTag3 = '<input type="button" value="Aper&ccedil;u" onclick="infoTarif('+identification+')" />';
						$('td:eq(5)', nRow).html(buttonTag3);
						var buttonTag4 = '<input type="button" value="Aper&ccedil;u" onclick="infoGalImage('+identification+')" />';
						$('td:eq(6)', nRow).html(buttonTag4);
						var buttonTag5 = '<input type="button" value="Valider" onclick="validClinique('+identification+')" />';				
						var isOK = aData['isOK'];
						if(isOK == 1){
							$('td:eq(7)', nRow).html("Validé");
						}else{
							$('td:eq(7)', nRow).html(buttonTag5);
						}
						var buttonTag6 = '<input type="button" value="Supprimer" onclick="supprimer('+identification+')" />';
						$('td:eq(8)', nRow).html(buttonTag6);
						var buttonTag7 = '<input type="button" value="Envoyer un email" onclick="infoGalImage('+identification+')" />';
						$('td:eq(9)', nRow).html(buttonTag7);
						return nRow;
					},									
					"aoColumns": [
						{ "mData": "id_clinique" },
						{ "mData": "logo" },
						{ "mData": "nom_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" },
						{ "mData": "id_clinique" }
					]
					});
				});
			} );
		</script>
		
	</head>
<body id="dt_tableresult">
<table>	
<tr>
    <td>Filtrer par :</td>
    <td>
    <select id="filtre" name="filtre" type="text" size="1" style="width:150px">
			<option value="1">Validé</option>
			<option value="2">En attente</option>
			<option value="3" selected="selected">Tous</option>	
    </select>
    </td>
  </tr>
<tr>
	<td colspan="2"><input type="button" value="Voir" id="Voir" /></td>
</tr>
</table>
	<br />
<div id="">
<div id="dynamic">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="tableresult">

	<thead>
		<tr>
			<th>Id</th>
			<th>Logo</th>
			<th>Nom de la clinique</th>
			<th>Informations sur la clinique</th>
			<th>Informations sur l'&eacute;quipe</th>
			<th>Informations sur les tarifs</th>
			<th>Gal&eacute;rie d'images</th>
			<th>Action1</th>
			<th>Action2</th>
			<th>Action3</th>
		
		</tr>
	</thead>
	<tbody>
	</tbody>
	
</table>
<div class="spacer"></div>
</div>
<div id="client_id">
</div>
<div id="invdate">
</div>
		</div>
		<div id="jsonValue"></div>
	</body>
</html>